
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    scoreLabel: cc.Label = null;

    @property(cc.Label)
    bulletLabel: cc.Label = null;

    @property(cc.Node)
    player:cc.Node=null

    @property(cc.Node)
    gameOverNode:cc.Node=null


    score:number=0;

    onLoad () {
        this.player.on('fire',this.updateBullet,this);
        cc.game.on('zombie-die',this.updateScore,this);
        cc.game.on('game-over',this.gameOver,this);
    }

    start () {
        
    }

    updateBullet(i:number){
        if(this.bulletLabel){
            this.bulletLabel.string=i+'';
        }
    }

    updateScore(add:any){
        cc.log(add.a);
        if(this.scoreLabel){
            this.score+=add.a;
            this.scoreLabel.string=this.score+'';
        }
    }

    gameOver(){
        this.gameOverNode.active=true;
    }

    resetGame(){
        cc.director.loadScene('main');
    }

    // update (dt) {}
}
